|
|
|
|
|
|
|
On Error GoTo PicErr ' in case user picks a bad file
If Len(CMDialog1.filename) <> 0 Then
Image1.Picture = LoadPicture(CMDialog1.filename)
End If
'
' all done, go to exit
GoTo PicExit
'
' handle bad picture error
PicErr:
MsgBox "Unable to load selected file.", vbExclamation, "Picture Error"
Resume Next
'
' final exit of procedure
PicExit:
'
End Sub |
|
|
|
|
|
|
|
|
The code in Listing 5.54 sets file type and caption properties of the common dialog box, runs the dialog, and then, if a file has been selected, attempts to save it to the image control. You add a little error trapping here in case the user selects an invalid file type. |
|
|
|
|
|
|
|
|
The last step in creating Visual Basic 5 data entry forms is adding the input validation routines. The following is a list of the input rules you should use when coding the validation routines: |
|
|
|
|
|
|
|
|
· The following fields are required for each form: |
|
|
|
 |
|
|
|
|
CompanyName |
|
|
|
 |
|
|
|
|
Addr1 |
|
|
|
 |
|
|
|
|
City |
|
|
|
 |
|
|
|
|
State/Province |
|
|
|
|
|
|
|
|
· The following dependent field rules apply to the form: |
|
|
|
 |
|
|
|
|
If the Addr2 field has data, the Addr1 field must have data. |
|
|
|
 |
|
|
|
|
If the FirstName field has data, the LastName field must have data. |
|
|
|
|
|
|
|
|
· The StateProv field should allow only uppercase data entry. |
|
|
|
|
|
|
|
|
First, set the UpperCase property of the vxtStateProv control to True. This forces all data input into this control to upper case. You can accomplish most of these validation checks using the Required property of the new VText control. However, you also need to call the conditionalValidate method for the three controls that require conditional input. |
|
|
|
|
|